package net.csdn.business.discuss.api.mapper;

import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import net.csdn.business.discuss.api.model.entity.DiscussVoteRecord;
import net.csdn.business.discuss.api.model.query.DiscussVoteRecordQuery;
import net.csdn.business.discuss.api.model.vo.DiscussVoteRecordVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * 讨论投票记录Mapper接口
 * 
 * @author ruoyi
 * @date 2023-07-25
 */
public interface DiscussVoteRecordMapper extends BaseMapper<DiscussVoteRecord>
{

    /**
     * 分页查询讨论投票记录列表
     *
     * @param query 字典类型信息
     * @return 字典类型集合信息
     */
    public List<DiscussVoteRecordVO> findPageList(Page page, @Param("query") DiscussVoteRecordQuery query);

    /**
     * 查询讨论投票记录
     * 
     * @param query 讨论投票记录主键
     * @return 讨论投票记录
     */
    @Select("<script> select * from discuss_vote_record where user_id=#{query.userId} " +
            "<if test='query.optionId != null and query.optionId!=\"\"' >" +
            " AND option_id=#{query.optionId} " +
            "</if>" +
            "<if test='query.discussId != null and query.discussId!=\"\"' >" +
            " AND discuss_id = #{query.discussId} " +
            "</if>" +
            "</script>")
    public DiscussVoteRecordVO selectDiscussVoteRecord(@Param("query")DiscussVoteRecordQuery query);

    /**
     * 查询讨论投票记录列表
     * 
     * @param query 讨论投票记录
     * @return 讨论投票记录集合
     */
    public List<DiscussVoteRecordVO> selectDiscussVoteRecordList(@Param("query") DiscussVoteRecordQuery query);

    /**
     * 新增讨论投票记录
     * 
     * @param discussVoteRecord 讨论投票记录
     * @return 结果
     */
    public Integer insertDiscussVoteRecord(DiscussVoteRecord discussVoteRecord);

    /**
     * 修改讨论投票记录
     * 
     * @param discussVoteRecord 讨论投票记录
     * @return 结果
     */
    public Integer updateDiscussVoteRecord(DiscussVoteRecord discussVoteRecord);

    /**
     * 删除讨论投票记录
     * 
     * @param discussId 讨论id
     * @return 结果
     */
    @Delete("delete from discuss_vote_record where discuss_id=#{discussId}")
    public Integer deleteVoteRecordByDiscussId(@Param("discussId")String discussId);

}
